Finding the directional derivatives of a function